SELECT T.*
FROM C1_NAVIGATION T
WHERE (sysdate BETWEEN t.BEGIN_DATE AND t.END_DATE)
AND EXISTS
  (SELECT 1
  FROM C1_ENTITY_TREE e
  JOIN c1_dictionary t_dictionary
  ON (t_dictionary.id = e.type_id)
  JOIN c1_dictionary_type t_dictionary_type
  ON (t_dictionary_type.id = t_dictionary.type_id)
  WHERE (sysdate BETWEEN e.BEGIN_DATE AND e.END_DATE)
  AND t_dictionary.code = 'Navigation'
  AND (sysdate BETWEEN t_dictionary.BEGIN_DATE AND t_dictionary.END_DATE)
  AND t_dictionary_type.code = 'table_info'
  AND (sysdate BETWEEN t_dictionary_type.BEGIN_DATE AND t_dictionary_type.END_DATE)
  AND e.entity_parent_id <#if (parentId??)>= :parentId<#else>IS NULL</#if>
  AND e.entity_id         = t.id
  )
ORDER BY t.order_code